From 78e4307aa50cd4dcef8734953393fcc617d49713 Mon Sep 17 00:00:00 2001 From: robertl Date: Thu, 13 Apr 2006 17:10:17 +0000 Subject: [PATCH] Improve groundspeak support in geoniche. (Working with Pasha on this...) --- gpsbabel/geoniche.c | 53 ++++++++++++++++++++++++++++++++++++++++++--- gpsbabel/util.c | 3 +++ 2 files changed, 53 insertions(+), 3 deletions(-) diff --git a/gpsbabel/geoniche.c b/gpsbabel/geoniche.c index 621221c80..385512cce 100644 --- a/gpsbabel/geoniche.c +++ b/gpsbabel/geoniche.c @@ -2,6 +2,7 @@ Read and write GeoNiche files. Copyright (C) 2003 Rick Richardson + Copyright (C) 2006 Robert Lipe This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -580,11 +581,55 @@ wpt2icon(const waypoint *wpt) else if (strstr(desc, "hyb")) return 47; else if (strstr(desc, "unk")) return 48; else if (strstr(desc, "cam")) return 49; - else return 0; + + switch (wpt->gc_data.type) { + case gt_traditional: return 43; + case gt_multi: return 44; + case gt_locationless: return 45; + case gt_earth: return 45; + case gt_virtual: return 45; + case gt_letterbox: return 46; + case gt_event: return 47; + case gt_cito: return 47; + case gt_suprise: return 48; + case gt_webcam: return 49; + } + + return 0; +} + +static char * +geoniche_geostuff(const waypoint *wpt) +{ + char *gs = NULL, *tmp1, *tmp2; + char tbuf[10240]; + + if (!wpt->gc_data.terr) { + return NULL; + } + + snprintf(tbuf, sizeof(tbuf), "\n%s by %s\n", gs_get_cachetype(wpt->gc_data.type), wpt->gc_data.placer); + gs = xstrappend(gs, tbuf); + + snprintf(tbuf, sizeof(tbuf), "Waypoint: %s %s\n", wpt->shortname, wpt->description); + gs = xstrappend(gs, tbuf); + + snprintf(tbuf, sizeof(tbuf), "Difficulty %3.1f, Terrain: %3.1f\n", wpt->gc_data.diff/10.0, wpt->gc_data.terr/10.0); + gs = xstrappend(gs, tbuf); + + tmp1 = strip_html(&wpt->gc_data.desc_short); + tmp2 = strip_html(&wpt->gc_data.desc_long); + gs = xstrappend(gs, tmp1); + gs = xstrappend(gs, tmp2); + + xfree(tmp1); + xfree(tmp2); + + return enscape(gs); } static void -copilot_writewpt(const waypoint *wpt) +geoniche_writewpt(const waypoint *wpt) { static int ct = 0; struct pdb_record *opdb_rec; @@ -634,6 +679,8 @@ copilot_writewpt(const waypoint *wpt) else notes = enscape(wpt->notes); + notes = xstrappend(notes, geoniche_geostuff(wpt)); + vdata = (ubyte *) xmalloc(vsize); if (vdata == NULL) fatal(MYNAME ": libpdb couldn't get record memory\n"); @@ -708,7 +755,7 @@ data_write(void) PdbOut->version = 0; PdbOut->modnum = 1; - waypt_disp_all(copilot_writewpt); + waypt_disp_all(geoniche_writewpt); pdb_Write(PdbOut, fileno(FileOut)); diff --git a/gpsbabel/util.c b/gpsbabel/util.c index 9d90b1066..bb645581b 100644 --- a/gpsbabel/util.c +++ b/gpsbabel/util.c @@ -223,6 +223,9 @@ xstrappend(char *src, const char *newd) if (!src) { return xxstrdup(newd, file, line); } + if (!newd) { + return xxstrdup(src, file, line); + } newsz = strlen(src) + strlen(newd) + 1; src = xxrealloc(src, newsz, file, line); -- 2.30.2